package game;

import static org.lwjgl.opengl.GL11.GL_MODELVIEW;
import static org.lwjgl.opengl.GL11.GL_PROJECTION;
import static org.lwjgl.opengl.GL11.GL_QUADS;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL11.glBegin;
import static org.lwjgl.opengl.GL11.glEnable;
import static org.lwjgl.opengl.GL11.glEnd;
import static org.lwjgl.opengl.GL11.glLoadIdentity;
import static org.lwjgl.opengl.GL11.glMatrixMode;
import static org.lwjgl.opengl.GL11.glOrtho;
import static org.lwjgl.opengl.GL11.glVertex2i;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.state.StateBasedGame;

import title.Title;
import world.World;

import combat.Combat;

public class Game extends StateBasedGame{
	
	
	public static final int HEIGHT = 600;
	public static final int WIDTH = 800;
	
	public static final String gameName = "RPG";
	public static final int TITLE = 0;
	public static final int WORLD = 1;
	public static final int COMBAT = 2;
	public static final int MENU = 3;
	
	static Texture titleScreen;
	

	public Game(String gameName){

		super(gameName);
		this.addState(new Title(TITLE));
		this.addState(new World(WORLD));
		this.addState(new Combat(COMBAT));
		this.addState(new Menu(MENU));
		
		
		
		
	}
	
	public void initStatesList(GameContainer gc) throws SlickException{
		
		this.getState(TITLE).init(gc, this);
		this.getState(WORLD).init(gc, this);
		this.getState(COMBAT).init(gc, this);
		this.getState(MENU).init(gc, this);
		this.enterState(TITLE);
	}

	public static void main(String[] args) {
		

		try {
			Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
			Display.setTitle(gameName);
			Display.create();
		} catch (LWJGLException e1) {
			e1.printStackTrace();
		}

		
		titleScreen = ImageLoader.loadImage("title/", "titleScreen");
		
		
		
		
		
		
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);
		glMatrixMode(GL_MODELVIEW);
		glEnable(GL_TEXTURE_2D);
		while(!Display.isCloseRequested()){
			
	
			
			glBegin(GL_QUADS);
			glVertex2i(0,0);
			glVertex2i(400,0);
			glVertex2i(400,600);
			glVertex2i(00,600);
			glEnd();
			
		
		
			
			Display.update();
			Display.sync(60);
			
		}
		
		Display.destroy();
/*
		AppGameContainer appgc;
		
		try{
			appgc = new AppGameContainer(new Game(gameName));
			appgc.setDisplayMode(WIDTH, HEIGHT, false);
			appgc.start();
		}catch(SlickException e){
			e.printStackTrace();}
	
*/
	}
}
